// https://leetcode.cn/problems/design-circular-queue/
// Created by ade on 2022/8/2.
//
#include <iostream>
#include <vector>

using namespace std;

struct Node {
    int val;
    Node *next;

    Node() : val(0), next(nullptr) {}

    Node(int val) : val(val), next(nullptr) {}

    Node(int val, Node *n) : val(val), next(n) {}
};


class MyCircularQueue {
public:
    int total = 0, count = 0;

    Node * head = nullptr;
    Node * index = nullptr;
    Node * rear = nullptr;

    MyCircularQueue(int k) {
        total = k;
    }

    bool enQueue(int value) {
        if (count + 1 > total)
            return false;
        Node * tmp = new Node(value);
        if(!head){
            head = tmp;
            index = head;
        } else{
            index->next = tmp;
            index = tmp;
        }

        rear = tmp;
        count++;
        return true;
    }

    bool deQueue() {
        if (count > 0) {
            Node * tmp = head;
            head = head->next;
            delete(tmp);
            count--;
            return true;
        }
        return false;
    }

    int Front() {
        if (count == 0) return -1;
        return head->val;
    }

    int Rear() {
        if (count == 0) return -1;
        return rear->val;
    }

    bool isEmpty() {
        return count == 0;
    }

    bool isFull() {
        return count == total;
    }
};

// ["MyCircularQueue","enQueue","Rear","Rear","deQueue","enQueue","Rear","deQueue","Front","deQueue","deQueue","deQueue"]
//[[6],[6],[],[],[],[5],[],[],[],[],[],[]]

int main() {
    MyCircularQueue so(6);
    so.enQueue(1);
    so.deQueue();
    so.enQueue(3);
    so.deQueue();
    if (so.enQueue(4)) {
        cout << "yes" << endl;
    } else {
        cout << "no" << endl;
    }
    cout << so.count << endl;
    cout << so.total << endl;
    return 0;
}